<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form>
        <label for="stu_id">
            学号：<input type="text" name="" id="stu_id"><br>
        </label>
        <label for="stu_name">
            姓名：<input type="text" name="" id="stu_name"><br>
        </label>
        <label for="stu_sex">
            性别：<input type="text" name="" id="stu_sex"><br>
        </label>
        <label for="stu_jg">
            籍贯：<input type="text" name="" id="stu_jg"><br>
        </label>
        <label for="stu_date">
            出生日期：<input type="text" name="" id="stu_date"><br>
        </label>
        <label for="stu_hobby">
            爱好：<input type="text" name="" id="stu_hobby"><br>
        </label>
        <label for="stu_gbf">
            男女朋友：<input type="text" name="" id="stu_gbf"><br>
        </label>
        <label for="stu_head_img">
            头像：<input type="text" name="" id="stu_head_img"><br>
        </label>
    </form>
    <button class="btn_student">学生信息提交</button>
    <script src="../../js/jquery-1.12.4.min.js"></script>
    <script>
        $('.btn_student').click((e)=>{
            e.preventDefault(); //取消浏览器的默认提交行为
            $.ajax({
                method:'post',
                url:'http://localhost:8080/student',
                data:{
                    stu_id:$('stu_id').val(),
                    stu_name:$('#stu_name').val(),
                    stu_sex:$('#stu_sex').val(),
                    stu_jg:$('#stu_jg').val(),
                    stu_date:$('#stu_date').val(),
                    stu_hobby:$('#stu_hobby').val(),
                    stu_gbf:$('#stu_gbf').val(),
                    stu_head_img:$('#stu_head_img').val()
                },
                success:(data)=>{
                    console.log(data);
                },
                error:(err)=>{
                    console.log(err);
                }
            })
        })
    </script>
</body>
</html>